package service;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import util.JsonTools;

import db.DBConn;
import entities.GoodsEntity;
import entities.OrderEntity;
import entities.OrderItemEntity;
import entities.SellerEntity;
import entities.UserEntity;

public class SellerService {
	public static List<SellerEntity> getAllSeller() throws SQLException {
		return getSeller(Integer.MAX_VALUE);
	}

	public static List<SellerEntity> getHotSeller() throws SQLException {
		return getSeller(11);
	}

	public static void checkSeller(String sellerIds) throws SQLException {
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "update shop_seller set seller_isVerify=1 where seller_id in "
				+ sellerIds;
		stmt.execute(sql);
		stmt.close();
		conn.close();
	}

	// 查询数据库 ，第一个参数：要查询前 n条记录
	private static List<SellerEntity> getSeller(int n) throws SQLException {
		List<SellerEntity> sellerList = new ArrayList<SellerEntity>();
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where seller_isVerify = 1  limit "
				+ n;
		ResultSet rs = stmt.executeQuery(sql);
		while (rs.next()) {
			SellerEntity seller = new SellerEntity();
			seller.setId(rs.getInt("seller_id"));
			seller.setName(rs.getString("seller_name"));
			seller.setLogoURL(rs.getString("seller_logo"));
			seller.setAddress(rs.getString("seller_addr"));
			seller.setTel(rs.getString("seller_tel"));
			seller.setDeliverTime(rs.getString("seller_deliverTime"));
			seller.setDesc(rs.getString("seller_desc"));
			seller.setRank(rs.getDouble("seller_rank"));
			seller.setOwner(rs.getString("seller_owner"));
			sellerList.add(seller);
		}
		rs.close();
		stmt.close();
		conn.close();
		return sellerList;
	}

	// 查询数据库 ，获得商家信息（审核的或者未审核的）
	public static List<SellerEntity> getSellers(int n) throws SQLException {
		List<SellerEntity> sellerList = new ArrayList<SellerEntity>();
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where seller_isVerify = " + n;
		ResultSet rs = stmt.executeQuery(sql);
		while (rs.next()) {
			SellerEntity seller = new SellerEntity();
			seller.setId(rs.getInt("seller_id"));
			seller.setName(rs.getString("seller_name"));
			seller.setEmail(rs.getString("seller_email"));
			seller.setLogoURL(rs.getString("seller_logo"));
			seller.setAddress(rs.getString("seller_addr"));
			seller.setTel(rs.getString("seller_tel"));
			seller.setDeliverTime(rs.getString("seller_deliverTime"));
			seller.setDesc(rs.getString("seller_desc"));
			seller.setRank(rs.getDouble("seller_rank"));
			seller.setOwner(rs.getString("seller_owner"));
			sellerList.add(seller);
		}
		rs.close();
		stmt.close();
		conn.close();
		return sellerList;
	}

	// 通过id获得商家信息
	public static SellerEntity getSellerById(int id) throws SQLException {
		SellerEntity seller = new SellerEntity();
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where seller_id =" + id;
		ResultSet rs = stmt.executeQuery(sql);
		while (rs.next()) {
			seller.setId(rs.getInt("seller_id"));
			seller.setName(rs.getString("seller_name"));
			seller.setLogoURL(rs.getString("seller_logo"));
			seller.setAddress(rs.getString("seller_addr"));
			seller.setTel(rs.getString("seller_tel"));
			seller.setDeliverTime(rs.getString("seller_deliverTime"));
			seller.setDesc(rs.getString("seller_desc"));
			seller.setRank(rs.getDouble("seller_rank"));
			seller.setOwner(rs.getString("seller_owner"));
		}
		rs.close();
		stmt.close();
		conn.close();
		return seller;
	}

	// 验证商家登录 frk 3月31号修改
	public static SellerEntity confirm(String sellerName, String password)
			throws SQLException {
		Connection conn = DBConn.getConn();
		SellerEntity seller = new SellerEntity();
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where (seller_name = '"
				+ sellerName + "' or seller_email = '" + sellerName
				+ "'  or seller_tel = '" + sellerName
				+ "' ) and seller_password = '" + password + "'";
		System.out.println(sql);
		ResultSet rs = stmt.executeQuery(sql);
		if (rs.next()) {
			seller.setId(rs.getInt("seller_id"));
			seller.setName(rs.getString("seller_name"));
			seller.setPassword(rs.getString("seller_password"));
			seller.setLogoURL(rs.getString("seller_logo"));
			seller.setAddress(rs.getString("seller_addr"));
			seller.setTel(rs.getString("seller_tel"));
			seller.setDeliverTime(rs.getString("seller_deliverTime"));
			seller.setDesc(rs.getString("seller_desc"));
			seller.setRank(rs.getDouble("seller_rank"));
			seller.setOwner(rs.getString("seller_owner"));
			seller.setRegTime(rs.getString("seller_regTime"));
			seller.setEmail(rs.getString("seller_email"));
		} else {
			seller = null;
		}
		rs.close();
		conn.close();
		return seller;
	}

	// frk 4月17日
	// 得到商家名为 *** 的商家
	public static SellerEntity getSeller(String sellerName) throws SQLException {
		SellerEntity seller = new SellerEntity();
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where seller_name like '"
				+ sellerName + "'";
		// System.out.println(sql);
		ResultSet rs = stmt.executeQuery(sql);
		while (rs.next()) {
			seller.setId(rs.getInt("seller_id"));
			seller.setName(rs.getString("seller_name"));
			seller.setOwner(rs.getString("seller_addr"));
			seller.setEmail(rs.getString("seller_email"));
			seller.setPassword(rs.getString("seller_password"));
			seller.setTel(rs.getString("seller_tel"));
			seller.setDeliverTime(rs.getTimestamp("seller_deliverTime")
					.toString());
			seller.setLogoURL(rs.getString("seller_logoURL"));
			seller.setDesc(rs.getString("seller_desc"));
			seller.setRank(rs.getDouble("seller_rank"));
		}
		rs.close();
		conn.close();
		return seller;
	}

	// frk21030423修改，用于商家相关数据统计
	public static int dataCount(String sql) throws SQLException {
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery(sql);
		System.out.println("112");
		int count;
		if (rs.next()) {
			count = rs.getInt(1);
		} else {
			count = 0;
		}
		return count;

	}

	// 获得商家销售额按月份获得订单已提交未付-------管理员
	public static Map<String, Double> getSellerCount(String saleDate)
			throws SQLException {
		String[] dateSplit = saleDate.split("-");
		// System.out.println(dateSplit[0]+"===="+dateSplit[1]);
		Map<String, Double> sellMap = new HashMap<String, Double>();
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_orderitem ,shop_seller,shop_goods where shop_orderitem.item_sellerId = shop_seller.seller_id and shop_orderitem.item_goodsId = shop_goods.goods_id and item_state > 0 and item_isPaid = 0";
		// System.out.println(sql);
		ResultSet rs = stmt.executeQuery(sql);
		while (rs.next()) {
			// int year = rs.getDate("item_addTime").getYear();
			String sellerName = rs.getString("seller_name");
			// System.out.println("^^^^^^^^^^^^^^"+sellerName);
			String date = rs.getDate("item_addTime").toString();
			String[] yearmonth = date.split("-");
			if (dateSplit[0].equals(yearmonth[0])
					&& dateSplit[1].equals(yearmonth[1])) {
				if (sellMap.containsKey(sellerName)) {
					Double sellPlus;
					int itemCount = rs.getInt("item_count");
					// System.out.println("if^^^^^^^^^^^^^^"+itemCount);

					Double goodsPrice = rs.getDouble("goods_price");
					// System.out.println("if^^^^^^^^^^^^^^"+goodsPrice);

					sellPlus = sellMap.get(sellerName) + itemCount * goodsPrice;
					sellMap.put(sellerName, sellPlus);
				} else {
					int itemCount = rs.getInt("item_count");
					// System.out.println("else^^^^^^^^^^^^^^"+itemCount);
					Double goodsPrice = rs.getDouble("goods_price");
					// System.out.println("else^^^^^^^^^^^^^^"+goodsPrice);

					sellMap.put(sellerName, itemCount * goodsPrice);
				}
			}

		}
		String result;
		result = JsonTools.createJsonString(sellMap);
		System.out.println("@#@#@#@#@#@#@#@#" + result + "@#@#@#@#@#@#@#");
		// System.out.println(sellMap.toString());
		rs.close();
		conn.close();
		return sellMap;
	}

	// 获得商家销售额按月份获得订单已提交已付----------管理员
	public static Map<String, Double> getSellerCounted(String saleDate)
			throws SQLException {
		String[] dateSplit = saleDate.split("-");
		// System.out.println(dateSplit[0]+"===="+dateSplit[1]);
		Map<String, Double> sellMap = new HashMap<String, Double>();
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_orderitem ,shop_seller,shop_goods where shop_orderitem.item_sellerId = shop_seller.seller_id and shop_orderitem.item_goodsId = shop_goods.goods_id and item_state > 0 and item_isPaid = 1 ";
		// System.out.println(sql);
		ResultSet rs = stmt.executeQuery(sql);
		while (rs.next()) {
			// int year = rs.getDate("item_addTime").getYear();
			String sellerName = rs.getString("seller_name");
			// System.out.println("^^^^^^^^^^^^^^"+sellerName);
			String date = rs.getDate("item_addTime").toString();
			String[] yearmonth = date.split("-");
			if (dateSplit[0].equals(yearmonth[0])
					&& dateSplit[1].equals(yearmonth[1])) {
				if (sellMap.containsKey(sellerName)) {
					Double sellPlus;
					int itemCount = rs.getInt("item_count");
					// System.out.println("if^^^^^^^^^^^^^^"+itemCount);

					Double goodsPrice = rs.getDouble("goods_price");
					// System.out.println("if^^^^^^^^^^^^^^"+goodsPrice);

					sellPlus = sellMap.get(sellerName) + itemCount * goodsPrice;
					sellMap.put(sellerName, sellPlus);
				} else {
					int itemCount = rs.getInt("item_count");
					// System.out.println("else^^^^^^^^^^^^^^"+itemCount);
					Double goodsPrice = rs.getDouble("goods_price");
					// System.out.println("else^^^^^^^^^^^^^^"+goodsPrice);

					sellMap.put(sellerName, itemCount * goodsPrice);
				}
			}

		}
		System.out.println(sellMap.toString());
		rs.close();
		conn.close();
		return sellMap;
	}
	
	// 获得商家销售额按月份获得订单已提交未付-------商家
		public static String getSellerCount(String saleDate,String sellerId)
				throws SQLException {
			String[] dateSplit = saleDate.split("-");
			// System.out.println(dateSplit[0]+"===="+dateSplit[1]);
			//Map<String, Double> sellMap = new HashMap<String, Double>();
			Connection conn = DBConn.getConn();
			Statement stmt = conn.createStatement();
			String sql = "select * from shop_orderitem ,shop_seller,shop_goods where shop_orderitem.item_sellerId = shop_seller.seller_id and shop_orderitem.item_goodsId = shop_goods.goods_id and item_state > 0 and item_isPaid = 0 and item_sellerId = " + sellerId + " order by item_addTime Desc";
			// System.out.println(sql);
			ResultSet rs = stmt.executeQuery(sql);
			Double monthTotle = 0.0;
			int rowCount = 0;
			while (rs.next()) {
				// int year = rs.getDate("item_addTime").getYear();
				//String sellerName = rs.getString("seller_name");
				// System.out.println("^^^^^^^^^^^^^^"+sellerName);
				String date = rs.getDate("item_addTime").toString();
				String[] yearmonth = date.split("-");
				if (dateSplit[0].equals(yearmonth[0])
						&& dateSplit[1].equals(yearmonth[1])) {
					
						Double sellPlus;
						int itemCount = rs.getInt("item_count");
						// System.out.println("if^^^^^^^^^^^^^^"+itemCount);

						Double goodsPrice = rs.getDouble("goods_price");
						// System.out.println("if^^^^^^^^^^^^^^"+goodsPrice);

						sellPlus = itemCount * goodsPrice;
						monthTotle = monthTotle + sellPlus;
						rowCount++;

				}
			}
			// System.out.println(sellMap.toString());
			double average;
			if(rowCount==0){
				average = 0;
			}else {
			Double averageSell = monthTotle/rowCount;
			BigDecimal b = new BigDecimal(averageSell);
			average = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
			}
			rs.close();
			conn.close();
			return "本月总销售额："+monthTotle+" 元；  共有订单："+rowCount+" 个  ；平均每单： "+average+" 元";
		}
		
		// 获得商家销售额按月份获得订单已提交已付----------商家
		public static Double getSellerCounted(String saleDate,String sellerId)
				throws SQLException {
			String[] dateSplit = saleDate.split("-");
			// System.out.println(dateSplit[0]+"===="+dateSplit[1]);
			Connection conn = DBConn.getConn();
			Statement stmt = conn.createStatement();
			String sql = "select * from shop_orderitem ,shop_seller,shop_goods where shop_orderitem.item_sellerId = shop_seller.seller_id and shop_orderitem.item_goodsId = shop_goods.goods_id and item_state > 0 and item_isPaid = 1 and item_sellerId = " + sellerId + " order by item_addTime Desc";
			// System.out.println(sql);
			ResultSet rs = stmt.executeQuery(sql);
			Double monthTotle = 0.0;
			while (rs.next()) {
				// int year = rs.getDate("item_addTime").getYear();
				//String sellerName = rs.getString("seller_name");
				// System.out.println("^^^^^^^^^^^^^^"+sellerName);
				String date = rs.getDate("item_addTime").toString();
				String[] yearmonth = date.split("-");
				if (dateSplit[0].equals(yearmonth[0])
						&& dateSplit[1].equals(yearmonth[1])) {
						Double sellPlus;
						int itemCount = rs.getInt("item_count");
						// System.out.println("if^^^^^^^^^^^^^^"+itemCount);

						Double goodsPrice = rs.getDouble("goods_price");
						// System.out.println("if^^^^^^^^^^^^^^"+goodsPrice);

						sellPlus = itemCount * goodsPrice;
						monthTotle = monthTotle + sellPlus;
				}

			}
			rs.close();
			conn.close();
			return monthTotle;
		}

		// 获得商家销售额按月份获得订单已提交情况----------商家
				public static List<OrderItemEntity> getOrderItem(String saleDate,String sellerId)
						throws SQLException {
					List<OrderItemEntity> orderItemList = new ArrayList<OrderItemEntity>();
					String[] dateSplit = saleDate.split("-");
					// System.out.println(dateSplit[0]+"===="+dateSplit[1]);
					//Map<String, Double> sellMap = new HashMap<String, Double>();
					Connection conn = DBConn.getConn();
					Statement stmt = conn.createStatement();
					String sql = "select * from shop_orderitem ,shop_user,shop_goods where shop_orderitem.item_userId = shop_user.user_id and shop_orderitem.item_goodsId = shop_goods.goods_id and item_state > 0  and item_sellerId = " + sellerId + " order by item_addTime Desc";
					// System.out.println(sql);
					ResultSet rs = stmt.executeQuery(sql);
					while (rs.next()) {
						OrderItemEntity orderItem = new OrderItemEntity();
						String date = rs.getDate("item_addTime").toString();
						String[] yearmonth = date.split("-");
						if (dateSplit[0].equals(yearmonth[0])
								&& dateSplit[1].equals(yearmonth[1])) {
							orderItem.setSaleTime(date);	
							orderItem.setOrderId(rs.getString("item_orderNo"));
							orderItem.setCliName(rs.getString("user_name"));
							orderItem.setFoodName(rs.getString("goods_name"));
							orderItem.setNumber(rs.getInt("item_count"));
							Double sellPlus;
							int itemCount = rs.getInt("item_count");
							Double goodsPrice = rs.getDouble("goods_price");
							sellPlus = itemCount * goodsPrice;
							orderItem.setMoney(sellPlus+"");
							orderItem.setIsPaid(rs.getInt("item_isPaid")>0?"是":"否");
							System.out.println(orderItem.toString());
							orderItemList.add(orderItem);

						}
						
					}
					System.out.println(orderItemList.toString());
					rs.close();
					conn.close();
					return orderItemList;
				}
				
				// 获得商家销售额按月份获得订单已提交情况1212121----------商家
				public static List<OrderEntity> getOrderDesc2(String saleDate,String sellerId,String start, String count)
						throws SQLException {
					List<OrderEntity> orderList = new ArrayList<OrderEntity>();
					String[] dateSplit = saleDate.split("-");
					// System.out.println(dateSplit[0]+"===="+dateSplit[1]);
					//Map<String, Double> sellMap = new HashMap<String, Double>();
					Connection conn = DBConn.getConn();
					Statement stmt = conn.createStatement();
					String sql = "select * from shop_order ,shop_user where order_userId = user_id and order_state > 0  and order_sellerId = " + sellerId + " order by order_addTime Desc limit " + start+ "," + count;
					System.out.println(sql);
					ResultSet rs = stmt.executeQuery(sql);
					while (rs.next()) {
						OrderEntity order = new OrderEntity();
						String date = rs.getDate("order_addTime").toString();
						String[] yearmonth = date.split("-");
						if (dateSplit[0].equals(yearmonth[0])
								&& dateSplit[1].equals(yearmonth[1])) {
							order.setTime(date);	
							order.setNo(rs.getString("order_no"));
							order.setToUser(rs.getString("user_name"));
							order.setToAddr(rs.getString("order_deliveryAddr"));
							order.setDetail(rs.getString("order_detail"));
							orderList.add(order);
						}
						
					}
				//	System.out.println(orderItemList.toString());
					rs.close();
					conn.close();
					return orderList;
				}
				
				// 获得商家销售额按月份获得订单已提交情况1212121dfdfdfd----------商家
				public static int getOrderCount(String saleDate,String sellerId)
						throws SQLException {
					List<OrderEntity> orderList = new ArrayList<OrderEntity>();
					String[] dateSplit = saleDate.split("-");
					// System.out.println(dateSplit[0]+"===="+dateSplit[1]);
					//Map<String, Double> sellMap = new HashMap<String, Double>();
					Connection conn = DBConn.getConn();
					Statement stmt = conn.createStatement();
					String sql = "select * from shop_order ,shop_user where order_userId = user_id and order_state > 0  and order_sellerId = " + sellerId + " order by order_addTime Desc ";
					System.out.println(sql);
					ResultSet rs = stmt.executeQuery(sql);
					int count =0;
					while (rs.next()) {
						OrderEntity order = new OrderEntity();
						String date = rs.getDate("order_addTime").toString();
						String[] yearmonth = date.split("-");
						if (dateSplit[0].equals(yearmonth[0])
								&& dateSplit[1].equals(yearmonth[1])) {
							order.setTime(date);	
							order.setNo(rs.getString("order_no"));
							order.setToUser(rs.getString("user_name"));
							order.setToAddr(rs.getString("order_deliveryAddr"));
							order.setDetail(rs.getString("order_detail"));
							orderList.add(order);
							count++;
						}
						
					}
				//	System.out.println(orderItemList.toString());
					rs.close();
					conn.close();
					return count;
				}
		
	// 检查是否有某一商家（针对修改）
	public static boolean checkSellerByName(String sellerName)
			throws SQLException {
		Connection conn = DBConn.getConn();
		boolean result = false;
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where seller_name like '"
				+ sellerName + "'";
		System.out.println(sql);
		ResultSet rs = stmt.executeQuery(sql);
		if (rs.first()) {
			result = true;
		}
		rs.close();
		conn.close();
		return result;
	}

	// 检查是否有某一商家
	public static boolean checkSellerByEmail(String email) throws SQLException {
		Connection conn = DBConn.getConn();
		boolean result = false;
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where seller_email like '"
				+ email + "'";
		System.out.println(sql);
		ResultSet rs = stmt.executeQuery(sql);
		if (rs.first()) {
			result = true;
		}
		rs.close();
		conn.close();
		return result;
	}

	// 检查是否有其他商家使用了某个邮箱
	public static boolean checkSellerByEmail(String sellerId, String email)
			throws SQLException {
		Connection conn = DBConn.getConn();
		boolean result = false;
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where sellerId !=" + sellerId
				+ " and  seller_email like '" + email + "'";
		System.out.println(sql);
		ResultSet rs = stmt.executeQuery(sql);
		if (rs.first()) {
			result = true;
		}
		rs.close();
		conn.close();
		return result;
	}

	// 检查是否有某一商家
	public static boolean checkSellerByPhone(String phone) throws SQLException {
		Connection conn = DBConn.getConn();
		boolean result = false;
		Statement stmt = conn.createStatement();
		String sql = "select * from shop_seller where seller_tel like '"
				+ phone + "'";
		System.out.println(sql);
		ResultSet rs = stmt.executeQuery(sql);
		if (rs.first()) {
			result = true;
		}
		rs.close();
		conn.close();
		return result;
	}

	// 添加操作
	public static String creatSeller(String name, String password,
			String mailBox, String phoneNum, String seller,
			String sellerAddress, String saleTime, String sellerLogo,
			String sellerDesc) throws SQLException {
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String sql = "insert into shop_seller values(null,'" + name + "','"
				+ password + "','" + mailBox + "','" + phoneNum + "','"
				+ seller + "','" + sellerAddress + "','" + saleTime + "','"
				+ sellerLogo + "',0,'" + sdf.format(new Date()) + "',0,'"
				+ sellerDesc + "',0.0,null,null,0.0,0.0)";
		long result = stmt.executeUpdate(sql);
		stmt.close();
		conn.close();
		return result > 0 ? "success" : "failed";
	}

	// 修改商家 的密码
	public static String changeSellerPassword(String sellerId, String password)
			throws SQLException {
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "update shop_seller set seller_password ='" + password
				+ "'  where seller_id =" + sellerId + "";
		System.out.println(sql + " ---修改密码语句");
		int rs = stmt.executeUpdate(sql);
		stmt.close();
		conn.close();
		return rs == 0 ? "failed" : "success";
	}

	// 修改商家logo 的图片
	public static String changeSellerLogo(String sellerId, String logo)
			throws SQLException {
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "update shop_seller set seller_logo='" + logo
				+ "'  where  seller_id = " + sellerId + "";
		System.out.println(sql + "---修改logo 的语句");
		int rs = stmt.executeUpdate(sql);
		conn.close();
		return rs == 0 ? "failed" : "success";
	}

	// 修改商家 的电话
	public static String changeSellerPhone(String sellerId, String phone)
			throws SQLException {
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "update shop_seller set seller_tel ='" + phone
				+ "'  where seller_id =" + sellerId + "";
		System.out.println(sql+ "----修改电话");
		int rs = stmt.executeUpdate(sql);
		stmt.close();
		conn.close();
		return rs == 0 ? "failed" : "success";
	}

	// 修改商家 基本信息
	public static String changeSellerInfo(String sellerId, String deliveryTime,
			String addr, String email, String desc) throws SQLException {
		Connection conn = DBConn.getConn();
		Statement stmt = conn.createStatement();
		String sql = "update shop_seller set seller_deliverTime ='"
				+ deliveryTime + "',seller_addr='" + addr + "', seller_email='"
				+ email + "',seller_desc='" + desc + "' where seller_id ="
				+ sellerId + "";
		System.out.println(sql + "----修改商家信息");
		int rs = stmt.executeUpdate(sql);
		stmt.close();
		conn.close();
		return rs == 0 ? "failed" : "success";
	}

	public static void main(String args[]) throws SQLException {
		 //System.out.println("#############################"+Integer.parseInt("01"));
		// System.out.println(getSellerById(2));
		// System.out.println(dataCount("Select count(*) from shop_goods where goods_sellerId=1 "));
		//getOrderItem("2013-03-11","1");
		//System.out.println(getSellerCount("2013-03","1")+"asasasasasasasasasasasasasasas");
	}
}
